package com.chun.mapper;

import com.chun.pojo.Emp;
import com.chun.pojo.GenderCountDTO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {
    //方法一
//    @Select("select count(*) from emp")
//    Long count();
//
//    @Select("select * from emp limit #{startIndex},#{pageSize}")
//    List<Emp> list(Integer startIndex, Integer pageSize);
    //方法二
    @Select("select * from emp")
    List<Emp> list();


    List<Emp> list2(String name, Short gender, Short job,LocalDate begin, LocalDate end);

    void deleteByIds(Integer[] ids);

    void add(Emp emp);

    Emp findById(Integer id);

    void update(Emp emp);

    @Select("select * from emp where username = #{username} and password = #{password}")
    Emp selectByName(Emp emp);
    @Delete(("delete from emp where dept_id = #{id}"))
    void deleteByDeptId(Integer id);

    @Select("select gender,count(*) as count from emp group by gender ")
    List<GenderCountDTO> getEmpGenderData();

    @Select("select distinct job from emp ")
    List<String> getJobList();

    @Select("select count(*) from emp group by job")
    List<Integer> getDataList();
}
